<template>
	<view class="page">
		<!--商品列表  -->
		<view class='goodList'>
			<scroll-view class="content" scroll-y @scrolltolower='loadMore' enable-back-to-top='true'>
				<navigator open-type="navigate" class='listItem' :url="'/pages/jewel/goods/show?goods_id='+item.id" v-for="(item, index) in datalist" :key="index">
					<image src="../../../static/icons/jewel/tip1.png" class="tips-pic" v-if="item.is_daiyan_zone == 1"></image>
					<image src="../../../static/icons/jewel/tip2.png" class="tips-pic" v-if="item.is_daiyan_zone == 0"></image>
					<view class='goodImgbox'>
						<image class='goodimg' :src='item.thumb'></image>
					</view>
					<view class='goodTitle'>{{item.goods_name}}</view>
					<view class="watch-slogan">{{item.show_return_title}}</view>
					<view class='goodTip'>
						<view class='goodPrice'>
							<view class='goodPrice-text'>¥</view>{{item.price}}
						</view>
						<view data-index='' class='user-coll' data-leaseid="">
							<text class='goodshoucang'>已售{{item.sales_sum}}</text>
						</view>
					</view>
				</navigator>
			</scroll-view>
		</view>
		
		<image src="../../../static/icons/transfer/rule-icon.png" class="rule-icon" @tap="showRule"></image>
		<view class="rule-mark" v-if="ruleShow" @tap="showRule"></view>
		<view class="g-popup-rule" v-if="ruleShow">
		    <view>爆款区规则</view>
		    <scroll-view class="content" scroll-y>
		    	<!-- <uParse :content="ruleData" @preview="preview" /> -->
				<view v-html="ruleData"></view>
		    </scroll-view>
		    <view class="g-popup-close" @tap="showRule">
		        <close size="40" color="#fff"></close>
		    </view>
		</view>
		
		<view class="m-loading" v-if="bIsShowLoading">
		    <image src="../../../static/images/loading.gif" mode="widthFix"></image>
		    <text>加载中</text>
		</view>
		<view class="m-no-data" v-if="showNodata">
			<image src="../../../static/images/no_data.png" mode="widthFix"></image>
		</view>
	</view>
</template>
<script>
	import henglang from '@/common/common_zb.js';
	export default {
		data() {
			return {
				datalist: [],	// 列表数据
				bIsShowLoading: false,
				page: 1,
				totalPages: 1,
				loadtype: 'normal',	// 加载数据方式
				showNodata:false,
				ruleShow: false,
				ruleData:''
			}
		},	
		onLoad() {
			let that = this
			that.getList();
			henglang.get('Goods/baokuan_rule',{}, false, function(res){
				if(res.data.code == 0){
					that.ruleData = res.data.data.list;
				}
			})
		},
		// 上拉加载
		onReachBottom(){
			this.loadMore()
		},
		methods: {
			// 获取列表数据
			getList(data){
				let that = this;
				if(that.page <= that.totalPages){
					that.bIsShowLoading = true;
					henglang.post('goods/searchGoods', {page:that.page,is_daiyan_zone:1}, false,function(res){
						that.bIsShowLoading = false;
						let data = res.data;
						if(data.count === 0){
							that.showNodata = true;
						}else{
							that.showNodata = false;
						};
						if(that.loadtype == 'plus') {
							that.datalist = that.datalist.concat(data.data);
						}else{
							that.datalist = data.data;
							that.totalPages = data.total_pages;
							uni.stopPullDownRefresh();
						}
					})
				}
			},
			loadMore(){
				this.loadtype = 'plus';
				this.page++;
				this.getList();
			},
			showRule() {
				this.ruleShow = !this.ruleShow;
			}
		}
	}
</script>

<style>
.page {
  overflow-x: hidden;
}
/*公共样式  */
page{
  font-size: 34rpx;
  background: #efefef;
}


/*商品列表  */
.goodList{
  width: 750rpx;
}
.listItem{
  width: 350rpx;
  background: #fff;
  margin: 15rpx 0 0 15rpx;
  border-radius: 6rpx;
  overflow: hidden;
  float: left;
  position: relative;
}
.listItem .tips-pic{
	position: absolute;
	top: 10rpx;
	left: 8rpx;
	width: 80rpx;
	height: 50rpx;
	z-index: 1;
}
.watch-slogan {
  border: 1px solid #fd6361;
  background: #fff;
  color: #fd6361;
  border-radius: 100rpx;
  margin-left: 15rpx;
  padding: 5rpx 10rpx;
  font-size: 24rpx;
  display: inline-block;
  margin-top: 6rpx;
}
.goodImgbox{
  width: 350rpx;
  height: 350rpx;
  text-align: center;
}
.goodImgbox .goodimg{
  width: 350rpx;
  height: 350rpx;
  border-radius: 6rpx;
}
.goodTitle{
  width: 350rpx;
  height: 90rpx;
  box-sizing: border-box; 
  padding: 15rpx 16rpx;
  padding-bottom: 0;
  color: #555;
  font-size: 25rpx;
  line-height:40rpx; 
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient: vertical;
}
.goodTitle text{
	color: #ffffff;
	background: #fd6361;
	border-radius: 3px;
	padding: 0 7rpx;
	margin-right: 10rpx;
}
.goodTip{
  box-sizing: border-box;
  padding: 15rpx;
  padding-top: 10rpx;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.goodPrice{
  font-size: 36rpx;
  float: left;
  color: #fd6361;
  font-weight: bold;
}
.goodPrice-text{
  font-size: 24rpx;
  display: inline-block
}
.user-coll{
  position: relative;
  top: -5rpx;
  float:right;
}

.goodshoucang{
  font-size: 24rpx;
  color: #999;
}


.m-no-data image{
	width: 100%;
	height: 100%;
}

/* 规则弹框 */
.rule-icon{
	position: fixed;
	bottom: 100rpx;
	right: 0;
	width: 154rpx;
	height: 154rpx;
	display: block;
	z-index: 1;
}
.rule-mark{
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	background: rgba(0,0,0,.5);
	height: 100%;
	z-index: 3;
}
.g-popup-rule {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: #fff;
	border-radius: 5px;
	width: 600rpx;
	padding: 20px;
	z-index: 100;
	font-size: 28rpx;
}

.g-popup-rule>view {
	padding-left: 10px;
	margin-bottom: 10px;
}

.g-popup-rule:after {
	content: '';
	display: block;
	width: 3px;
	height: 15px;
	background: #d71311;
	position: absolute;
	top: 21px;
	left: 10px;
}
.g-popup-rule .content{
	max-height: 500rpx;
}
.g-popup-rule .g-popup-close {
	padding: 5px;
	border-radius: 100px;
	border: 3px solid #fff;
	position: absolute;
	bottom: -60px;
	left: 50%;
	transform: translateX(-50%);
}
</style>